home *** CD-ROM | disk | FTP | other *** search
- /* open,open.c -
- /* going-away present for our good,good friend Lynn Civello, also */
- /* known as Lynnis, who is going off to charm Massachusetts. */
- /* causes a recording of Lynn saying "open,open,open" to play at */
- /* each launch */
- /* © copyright 1992, Eric Slosser, all rights reserved */
-
- #include <SetupA4.h>
- #include <Sound.h>
- #include <Traps.h>
- #include <Processes.h>
-
- pascal extern void SHOWINIT(short iconID, short moveX);
-
- typedef pascal short (*TrackType) (ControlHandle,Point,ProcPtr);
- typedef pascal short (*LaunchType) (LaunchParamBlockRec *params);
-
- TrackType gOldTrackControl;
- LaunchType gOldLaunch;
- long gOldMenuDispatch;
-
- long gDirID;
- short gVRefNum;
- Str31 gName;
-
- Str15 kOpen = "\pOpen";
-
- /*------------------------------*/
- pascal short myTrackControl( ControlHandle ctl, Point p, ProcPtr action );
- pascal short myLaunch( LaunchParamBlockRec *params );
- pascal short myMenuDispatch( short selector );
- int pstrcmp ( StringPtr s, StringPtr t );
-
- /*------------------------------*/
- void PlaySound(void);
- void PlaySound(void)
- {
- short saved,resRef;
- Handle soundH;
-
- saved = CurResFile();
- resRef = HOpenResFile( gVRefNum, gDirID, gName, fsRdPerm);
- if ( resRef>0 ) {
- UseResFile(resRef);
- if (soundH = GetResource('snd ',128)) {
- DetachResource(soundH);
- SndPlay(nil,soundH,true);
- }
- CloseResFile(resRef);
- UseResFile(saved);
- }
- }
- /*------------------------------*/
- pascal short myTrackControl(
- ControlHandle ctl,
- Point p,
- ProcPtr action )
- {
- short part;
- unsigned char *cTitle;
-
- SetUpA4();
- part = (*gOldTrackControl)( ctl,p,action ); /* can you say "tail patch"? */
- if ( part==inButton ) {
- cTitle = (**ctl).contrlTitle;
- if (!pstrcmp(cTitle,kOpen) )
- PlaySound();
- }
- RestoreA4();
- return(part);
- } /* myTrackControl */
- /*------------------------------*/
- pascal short myLaunch(
- LaunchParamBlockRec *params )
- {
- SetUpA4();
- PlaySound();
- gOldLaunch(params);
- RestoreA4();
- } /* myLaunch */
- /*------------------------------*/
- pascal short myMenuDispatch( short selector )
- {
- SetUpA4();
- if ( selector==1 )
- PlaySound();
- asm {
- move.l gOldMenuDispatch,a0
- move.l (sp)+,a4 /* RestoreA4 */
- unlk a6
- jmp (a0)
- }
- } /* myLaunch */
- /*------------------------------*/
- void SaveResFileInfo(void);
- void SaveResFileInfo(void)
- {
- Handle h;
- short resRef;
- FCBPBRec pb;
-
- asm {
- RecoverHandle
- move.l a0,h
- }
-
- resRef = HomeResFile(h);
- DetachResource(h);
-
- pb.ioFCBIndx = 0;
- pb.ioFCBIndx = 0;
- pb.ioNamePtr = gName;
- pb.ioRefNum = resRef;
- PBGetFCBInfo(&pb,false);
-
- gVRefNum = pb.ioFCBVRefNum;
- gDirID = pb.ioFCBParID;
- }
- /*------------------------------*/
- int pstrcmp ( StringPtr s, StringPtr t )
- {
- register int i;
-
- if ( *s != *t )
- return ( *s - *t ); /* >0 if s is longer, <0 is t is longer */
-
- for ( i=*s; *s==*t && i>=0; s++,t++,i-- )
- ;
-
- if ( i<0 )
- return( 0 );
- else
- return ( *s - *t );
- }
- /*------------------------------*/
- main()
- {
- #define _MenuDispatch 0xa825
- RememberA0();
- SetUpA4();
-
-
- SaveResFileInfo();
-
- gOldTrackControl = (TrackType) NGetTrapAddress(_TrackControl,ToolTrap);
- NSetTrapAddress( (long) myTrackControl,_TrackControl,ToolTrap);
-
- gOldLaunch = (LaunchType) NGetTrapAddress(_Launch,ToolTrap);
- NSetTrapAddress( (long) myLaunch,_Launch,ToolTrap);
-
- gOldMenuDispatch = NGetTrapAddress(_MenuDispatch,ToolTrap);
- NSetTrapAddress( (long) myMenuDispatch,_MenuDispatch,ToolTrap);
-
- SHOWINIT(128,-1);
-
- RestoreA4();
- }
- /*------------------------------*/
-